<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2022/1/18
  Time: 15:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="../static/js/jquery-3.4.1.js"></script>
    <script>
            function login(){
                var loginform = $("#loginform").serializeArray();
                $.ajax({
                    url:"../user/login",
                    data:loginform,
                    type:"post",
                    dataType:"json",
                    success:function (data){
                        if (data.length==0){
                            alert("登录失败");
                            location.href="../page/login";
                        }else{
                            alert("登录成功");
                            location.href="/page/update";
                        }
                    }
                })
                return false;
            }
    </script>
</head>
<style>
    body{
    background-color: #A9E2F3;
    }
    table,form{
        margin-left: auto;
        margin-right: auto;
        margin-top: 200px;
    }
    td{
        padding-top:15px;
        padding-bottom:15px;
    }

</style>
<body >
<form action="" id="loginform" onsubmit="return login()"  style="background-color: #f0f8ff;width:400px;" >
    <table  <%--border="1px solid red"--%> cellspacing="0px" >
        <caption><h3>高校点名考勤系统</h3></caption>
        <tr>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>用户名:</td>
            <td>
                <input type="text" name="username" placeholder="请输入用户名">
            </td>
        </tr>
        <tr>
            <td>密码:</td>
            <td>
                <input type="text" name="password" placeholder="请输入密码">
            </td>
        </tr>
        <tr>
            <td>用户角色:</td>
            <td>
                <select name="role" id="role" size="1">
<%--                <option></option>--%>
                <option selected value="1">学生</option>
                <option value="2">任课老师</option>
                <option value="3">系统管理员</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div align="center">
                    <input type="submit" value="登录">
                    <input type="reset" value="重置">
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div align="center">
                    <span color="red">是否已有账号？</span>
                    <a href="/page/register">点击注册</a>用户角色
                </div>
            </td>
        </tr>
    </table>
</form>
</body>
</html>
